package com.euond.permission.api;

import com.euond.permission.service.UserPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by user on 2018/7/9.
 */
@RestController
@RequestMapping("/permission/api/userpermissions")
public class UserPermissionFeignController {

    @Autowired
    UserPermissionService userPermissionService;

    /**
     * 获取用户的角色权限（shiro角色授权认证）
     */
    @GetMapping("/roles")
    public List<String> findStringRoles(@RequestParam(required = false) Long userId) {
        List<String> roleList = userPermissionService.findStringRoles(userId);
        return roleList;
    }

    /**
     * 获取用户的资源权限（shiro资源授权认证）
     */
    @GetMapping("/permissions")
    public List<String> findStringPermissions(@RequestParam(required = false) Long userId) {
        List<String> permissionList = userPermissionService.findStringPermissions(userId);
        return permissionList;
    }
}
